<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>消息列表--layui后台管理模板</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="../../js/layui/css/layui.css" media="all" />
<script src="../../js/layui/layui.js"></script>
<link rel="stylesheet" href="../../css/font_eolqem241z66flxr.css"
	media="all" />
<link rel="stylesheet" href="../../css/message.css" media="all" />
<style type="text/css">
.layui-table-cell {
	text-align: center;
}
</style>
</head>
<body class="childrenBody">
	<form class="layui-form" method="post" onsubmit="return false;">
		<blockquote class="layui-elem-quote news_search">

			<div class="layui-inline selectMsg">
				<select name="state" lay-filter="selectMsg" id="state">
					<option value="">全部</option>
					<option value="未读">未读</option>
					<option value="已读">已读</option>
					<option value="已回复">已回复</option>
				</select>
			</div>
			<div class="layui-input-inline" style="width: 100px;">
				<button class="layui-btn" id="search" data-type="reload">搜索</button>
			</div>
			<div class="layui-input-inline" style="width: 100px;">
				<button class="layui-btn" id="LooksAll" data-type="reload">一键已读</button>
			</div>
		</blockquote>
		<table class="layui-table msg_box" lay-skin="line" id="Ly"
			lay-filter="LyTable">

			<tbody class="msgHtml"></tbody>
		</table>
	</form>
	<script type="text/html" id="barDemo">
		<a class="layui-btn  layui-btn-sm" lay-event="fill"><i class="layui-icon layui-icon-reply-fill"></i>查看</a>
		</script>
	<script type="text/javascript">
		layui.use([ 'table', 'layer' ], function() {
			var table = layui.table, $ = layui.$, layer = layui.layer;
			table.render({
				elem : '#Ly',

				url : '../../../LyServlet?reqName=selectLyAll' //数据接口
				,
				page : true,
				cols : [ [ //表头

				{
					type : 'checkbox'
				}, {
					field : 'lyId',
					title : '编号',
					width : 74,

					sort : true
				}, {
					field : 'lyName',
					title : '用户名',
					width : 90
				}, {
					field : 'lyContent',
					title : '留言',
					width : 210
				}, {
					field : 'lyTime',
					title : '时间',
					width : 200,
					sort : true

				}, {
					field : 'lyPhone',
					title : '电话',
					width : 120,

				}, {
					field : 'lyEmail',
					title : '邮箱',
					width : 200,

				}, {
					field : 'lyState',
					title : '状态',
					width : 90,

				},

				{
					title : '操作',
					align : 'center',
					fixed : 'right',
					width : 120,
					toolbar : '#barDemo'
				}

				] ],
				id : "NewsReload"
			});
			$("#search")
			.click(
					function() {
						table
								.reload(
										'NewsReload',
										{
											url : '../../../LyServlet?reqName=selectLyAll',
											page : {
												curr : 1
											//重新从第 1 页开始
											},
											where : {
												state : $(
														"#state")
														.val()
											}
										});
					});
			$("#LooksAll")
			.click(
					function() {
						table
								.reload(
										'NewsReload',
										{
											url : '../../../LyServlet?reqName=looksAll',
											page : {
												curr : 1
											//重新从第 1 页开始
											},
											where : {
												state : $(
														"#state")
														.val()
											}
										});
						location.reload();
					});
			table.on('tool(LyTable)', function(obj) {
				var data = obj.data; //获得当前行数据
				var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
				var tr = obj.tr; //获得当前行 tr 的 DOM 对象（如果有的话）
				sessionStorage.setItem("message", JSON.stringify(data));
				if (layEvent === 'fill') { //编辑

					var index = layui.layer.open({
						title : "回复留言",
						type : 2,
						content : "messageReply.html",
						success : function(layero, index) {
							layui.layer.tips('点击此处返回留言列表',
									' .layui-layer-close', {
										tips : 3
									});
						},
						end : function() {
							location.reload();
						}
					})

					$(window).resize(function() {
						layui.layer.full(index);
					})
					layui.layer.full(index);
					if (data.lyState == "已读" || data.lyState == "已回复") {

					} else {
						layui.layer.full(index);
						$.post('../../../LyServlet?reqName=updateLy', {
							id : data.lyId
						}, "text")
					}

				}
			});
		})
	</script>
	<!-- <script type="text/javascript" src="message.js"></script> -->
</body>
</html>